package com.hugy.redis.controller;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class AccessInterceptor {

    @Pointcut("within(@com.hugy.redis.config.AccessAnnotation *)")
    public void accessController(){}


    @Before("accessController()&&@annotation(gm)")
    public void doBefore(JoinPoint joinPoint, GetMapping gm) throws Throwable {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        String session = request.getHeader("session");
    }

}
